<template>
  <div class="todo-footer">
    <label>
      <input
        type="checkbox"
        @change="checkedAllHandler"
        :checked="
          todoDone === todoList.length && todoList.length !== 0 ? true : false
        "
      />
    </label>
    <span>
      <span>已完成{{ todoDone }}</span> / 全部{{ todoList.length }}
    </span>
    <button class="btn btn-danger" @click="deleteAllHandler">
      清除已完成任务
    </button>
  </div>
</template>

<script>
export default {
  name: "Footer",
  props: ["todoList", "checkedAll", "deleteAll"],
  methods: {
    checkedAllHandler(e) {
      this.checkedAll(e.target.checked);
    },
    deleteAllHandler() {
      this.deleteAll();
    },
  },
  computed: {
    todoDone() {
      const re = this.todoList.filter((item) => {
        return item.isChecked === true;
      });
      return re.length;
    },
  },
  
};
</script>

<style>
/*footer*/
.todo-footer {
  height: 40px;
  line-height: 40px;
  padding-left: 6px;
  margin-top: 5px;
}

.todo-footer label {
  display: inline-block;
  margin-right: 20px;
  cursor: pointer;
}

.todo-footer label input {
  position: relative;
  top: -1px;
  vertical-align: middle;
  margin-right: 5px;
}

.todo-footer button {
  float: right;
  margin-top: 5px;
}
</style>